package spy

import (
	"banzhuan-sys/strategy/aimsite"
	"github.com/gin-gonic/gin"
	"net/http"
)

func Crawl(ctx *gin.Context) {

	aim := ctx.Query("aim")

	var aimSite aimsite.AimSite

	switch aim {
	case "dy":
		aimSite = &aimsite.DianYa{}
		break
	case "hslm":
		aimSite = &aimsite.Huashilm{}
		break
	case "ydy":
		aimSite = &aimsite.DuiYou{}
		break
	case "xmf":
		aimSite = &aimsite.Xmf{}
		break
	default:
		return
	}

	ok,err := aimSite.Run()
	if !ok {

		ctx.JSON(http.StatusOK, gin.H{
			"code": "0000",
			"msg":  err.Error(),
			"data": aim,
		})
		return
	}


	ctx.JSON(http.StatusOK, gin.H{
		"code": "0000",
		"msg":  "ok",
		"data": aim,
	})

}
